from Base.Base import Base
from selenium.webdriver.common.by import By
import os
import time


class Page(Base):
    url = os.getenv("base_url")
    login_name = (By.ID, 'userName')
    login_pwd = (By.ID, 'password')
    login_jin = (By.XPATH, '/html/body/div[2]/div/div/div/div/div[3]/div[1]/div/form/div[1]/div[4]/button')

    def deng_name(self):
        self.clear(self.login_name)
        self.send_keys(self.login_name, 'admin')

    def deng_pwd(self):
        self.clear(self.login_pwd)
        self.send_keys(self.login_pwd, 'llg123')

    def deng_lu(self):
        self.click(self.login_jin)

    def deng_go(self):
        self.open_url("http://82.157.138.248:8080/jeewms/")
        print("打开网址")
        time.sleep(2)
        self.deng_name()
        self.deng_pwd()
        print("输入账号密码")
        time.sleep(6)
        self.deng_lu()
        time.sleep(5)

